home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
JCSM Shareware Collection 1996 September
/
JCSM Shareware Collection (JCS Distribution) (September 1996).ISO
/
prgtools
/
wformpas.zip
/
test.old
< prev
next >
Wrap
Text File
|
1994-04-04
|
4KB
|
150 lines
{programm : wbild.pas
Funktion : Anzeige der bildwiederholungsfrequenz unter Windows
Autor : Wilfried Lottermoser
}
program wbild;
Uses owindows,wintypes,winprocs,strings,windos;
Type
TMyApplication = object(tapplication)
Procedure initmainwindow; virtual;
Function processappmsg(var message:tmsg):boolean;virtual;
End;
PFenster = ^TFenster;
Tfenster = object (twindow)
WDC:HDC;
gett:real;
f:array[0..9] of real;
Count:byte;
busy:boolean;
xres,yres:string;
Constructor init (Mutterfenster: pwindowsobject;ztitel: pchar);
Procedure sync;
Procedure getwindowclass(var awndclass:twndclass);virtual;
Procedure GetFreq(var msg:tmessage);virtual wm_first+ wm_user;
Procedure display(strg:string);
Function canclose:boolean;virtual;
Destructor done;virtual;
End; {tfenster}
Var MyApp:tmyapplication;
{------------------------------------------------------------------------}
Procedure tmyapplication.initmainwindow;
Begin
Mainwindow := new(pfenster, init(nil, 'wbild'));
End;
Function tmyapplication.processappmsg(var message:tmsg):boolean;
Begin
If (message.message = wm_timer)then begin
Sendmessage(mainwindow^.hwindow,wm_user,0,0);
End;
Processappmsg:=tapplication.processappmsg(message);
End;
{------------------------------------------------------------------------}
Constructor tfenster.init(mutterfenster: pwindowsobject;ztitel: pchar);
Var t :word;
Begin
Twindow.init(mutterfenster,ztitel);
{ zeitgeber mit 2-sekundentakt setzen}
If settimer(hwindow,1,3000,nil)=0 then
Messagebox(hwindow,'fehler beim anlegen des zeitgebers','',mb_ok);
For t:=0 to 9 do f[t]:=0;count:=0;
Attr.w:=170;attr.h:=60;
Str(getsystemmetrics(sm_cxscreen),xres);
Str(getsystemmetrics(sm_cyscreen),yres);
End;
Procedure tfenster.getwindowclass;
Begin
Inherited getwindowclass(awndclass);
Awndclass.style:=awndclass.style or cs_dblclks;
Awndclass.hicon:=0; { hiermit wird die Symbolanzeige aktiviert}
End;
Procedure tfenster.sync; { Synchronisation mit vertikalem Kathodenstrahlrueckgang }
Var m:tmsg;
Begin
Repeat until (port[$3da] and 8)=0;
Repeat until (port[$3da] and 8)=8;
{ankommende botschaften weiterleiten}
If peekmessage(m,0,0,0,pm_remove) then begin
Translatemessage(m); dispatchmessage(m);
End;
End;
Procedure tfenster.getfreq(var msg:tmessage);
Const SyncCount = 100;
Var
strg:string;
h,h2,m,m2,s,s2,s100,s200,i:word;
freq:real;
Begin
busy:=true;
If f[1]=0 then display('wait');
inc(count);
Count:=count mod 10;
sync;
Gettime(h,m,s,s100);
For i:=1 to synccount do sync;
Gettime(h2,m2,s2,s200);
f[count]:=synccount/(100*(h2*36+m2*0.6+s2/100+s200/10000-h*36-m*0.6-s/100-s100/10000));
freq:=0;
For i:=0 to 9 do freq:=freq+f[i];
freq:=freq/10;
Str(freq:3:2,strg);
If not isiconic(hwindow) then display(xres+'*'+yres+' v='+strg+'hz') else display(strg);
busy:=false;
End;
Procedure tfenster.display(strg:string);
Var
AChar :array[0..255] of char;
rect:trect;
Begin
Strpcopy(achar,strg);
Wdc:=getdc(hwindow);
Setbkcolor(wdc,rgb(0,170,0)); {Hintergrundfarbe grⁿn}
Settextalign(wdc,ta_center or ta_bottom); {Text zentriert}
With rect do begin
left:=0; right:=attr.w; top:=0; bottom:=attr.h;
End;
If isiconic(hwindow) then exttextout(wdc,18,25,eto_opaque,@rect,achar,strlen(achar),nil) else
Begin
Exttextout(wdc,attr.w div 2,attr.h div 2,eto_opaque,@rect,achar,strlen(achar),nil);
End;
Releasedc(hwindow,wdc);
End;
Function tfenster.canclose:boolean;
Var m:tmsg;
Begin
display('end');
Canclose:=not busy;
{wenn gerade eine Zeitmessung erfolgt die Botschaft wm_close aufschieben}
m.message:=wm_close;
If busy then dispatchmessage(m);
End;
Destructor tfenster.done;
Var
m:tmsg;
ms:tmessage;
Begin
Killtimer(hwindow,1); {Zeitgeber entfernen}
Twindow.done;
End;
{------------------------------------------------------------------------}
Begin
Myapp.init('');
Myapp.run;
Myapp.done;
End.